package com.wholesale.beans;

import org.json.JSONException;
import org.json.JSONObject;

public class Country {

	private int regionId ;
	private int parentId ;
	private String regionName ;
	private int regionType ;
	private int agencyId ;
	private JSONObject jsonObject;
	public int getRegionId() {
	
		return regionId;
	}
	public void setRegionId(int regionId) {
		this.regionId = regionId;
	}
	public int getParentId() {
		
		return parentId;
	}
	public void setParentId(int parentId) {
		this.parentId = parentId;
	}
	public String getRegionName() {
		
		return regionName;
	}
	public void setRegionName(String regionName) {
		this.regionName = regionName;
	}
	public int getRegionType() {
		
		return regionType;
	}
	public void setRegionType(int regionType) {
		this.regionType = regionType;
	}
	public int getAgencyId() {
		
		return agencyId;
	}
	public void setAgencyId(int agencyId) {
		this.agencyId = agencyId;
	}
	
	public String toJsonString(){
		JSONObject loginObject = new JSONObject();
		try {
			loginObject.put("regionId", regionId);
			loginObject.put("parentId", parentId);
			loginObject.put("regionName", regionName);
			loginObject.put("regionType", regionType);
		} catch (Exception e) {
		}
		return loginObject.toString();
	}
	
	public void jsonAnalytic(String jsonString){
		try {
			jsonObject = new JSONObject(jsonString);
		jsonAnalytic(jsonObject);
		} catch (JSONException e) {
			
			e.printStackTrace();
		}
	}
	
	public void jsonAnalytic(JSONObject jsonObject){
		this.jsonObject = jsonObject;
		
			try {
				parentId = jsonObject.getInt("parentId");
			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			try {
				regionId = jsonObject.getInt("regionId");
			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			try {
				regionName = jsonObject.getString("regionName");
			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			try {
				regionType = jsonObject.getInt("regionType");
			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			try {
				agencyId = jsonObject.getInt("agencyId");
			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		
	}
}
